let { SyncBailHook } = require('tapable')

class Lesson1 {
  constructor () {
    this.hooks = {
      arch: new SyncBailHook(['name'])
    }
  }

  // 注册监听函数
  tap () {
    this.hooks.arch.tap('node', (name) => {
      console.log('node', name)
      return '我要停止！'
    })
    this.hooks.arch.tap('react', (name) => {
      console.log('react', name)
    })
  }

  start () {
    this.hooks.arch.call('xyf')
  }
}

let l1 = new Lesson1()

l1.tap()
l1.start() // 启动钩子

console.log('----------------------------------')

class Lesson2 {
  constructor () {
    this.hooks = {
      arch: new SyncBailHook(['name'])
    }
  }

  // 注册监听函数
  tap () {
    this.hooks.arch.tap('node', (name) => {
      console.log('node', name)
      return undefined
    })
    this.hooks.arch.tap('react', (name) => {
      console.log('react', name)
    })
  }

  start () {
    this.hooks.arch.call('xyf')
  }
}

let l2 = new Lesson2()

l2.tap()
l2.start() // 启动钩子
